package com.qf.order.controller;


import com.qf.common.annotation.Anonymous;
import com.qf.common.utils.Result;
import com.qf.order.domain.dto.OrderAnalysisDTO;
import com.qf.order.domain.dto.OrderDistributionDTO;
import com.qf.order.domain.dto.OrderStatsDTO;
import com.qf.order.domain.dto.OrderTrendDTO;
import com.qf.order.service.OrderAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单分析控制器
 */
@RestController

@RequestMapping("/tms/order/analysis")
@Api(tags = "订单分析接口")
public class OrderAnalysisController {

    @Autowired
    private OrderAnalysisService orderAnalysisService;

    /**
     * 获取订单统计数据
     */
    @GetMapping("/stats")
    @ApiOperation("获取订单统计数据")
    @Anonymous
    public Result<OrderStatsDTO> getOrderStats(OrderAnalysisDTO params) {
        System.out.println(params);
        return Result.success(orderAnalysisService.getOrderStats(params));
    }

    /**
     * 获取订单趋势数据
     */
    @GetMapping("/trend")
    @ApiOperation("获取订单趋势数据")
    @Anonymous
    public Result<OrderTrendDTO> getOrderTrend(OrderAnalysisDTO params) {
        return Result.success(orderAnalysisService.getOrderTrend(params));
    }

    /**
     * 获取订单分布数据
     */
    @GetMapping("/distribution")
    @ApiOperation("获取订单分布数据")
    @Anonymous
    public Result<OrderDistributionDTO> getOrderDistribution(OrderAnalysisDTO params) {
        return Result.success(orderAnalysisService.getOrderDistribution(params));
    }
}
